package com.zezheng.qian.project.anxinsign.dto.response;

import com.zezheng.qian.project.anxinsign.dto.Head;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author kou
 * @date 2020-04-23
 */
@Data
@ApiModel(description = "响应结果")
public class ResponseDTO<T> {

    public static <T> ResponseDTO<T> success(Head header, T body, Object res, Object req, String url) {
        return new ResponseDTO<>(header, body, res, req, url);
    }

    public static <T> ResponseDTO<T> success(Head header, T body) {
        return new ResponseDTO<>(header, body, null, null, null);
    }

    public static <T> ResponseDTO<T> error(String msg) {
        Head Head = new Head();
        Head.setRetCode("-1");
        Head.setErrorMessage(msg);
        return new ResponseDTO<>(Head, null, null, null, null);
    }

    @ApiModelProperty("响应头")
    private Head header;

    @ApiModelProperty("响应体")
    private T body;

    @ApiModelProperty("ufxRes")
    private Object ufxRes;

    @ApiModelProperty("ufxReq")
    private Object ufxReq;

    @ApiModelProperty("ufxUrl")
    private Object ufxUrl;

    public ResponseDTO() {
    }

    public ResponseDTO(Head header, T body, Object res, Object req, Object url) {
        this.header = header;
        this.body = body;
        this.ufxRes = res;
        this.ufxReq = req;
        this.ufxUrl = url;
    }
}
